package com.itheima.job2;

public class Point {
    private  int ticket = 100;

    public int getTicket() {
        return ticket;
    }

    //站点1 站点2 站点3 买票
    public void saleTicket(){
        String name = Thread.currentThread().getName();
        while(true) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
           synchronized (this) {
               if (ticket > 0) {

                   ticket--;
                   System.out.println(name + "卖出一张票:" + ticket);
               } else {
                   break;
               }
           }
        }

    }
}
